import re
import openpyxl
import  os

def CreateXlsx():
    workbook = openpyxl.Workbook()
    sheet=workbook.active
    sheet.column_dimensions['A'].width = 56
    sheet.column_dimensions['B'].width = 50
    sheet.column_dimensions['C'].width = 25
    sheet.append(['data','name','version'])
    AutoFind(sheet)
    workbook.save('copyright.xlsx')

def AutoFind(sheet):
    for line in open("新建文本文档.txt",encoding='UTF-8'):
        if(line.find('Software: ') == 0):
            version = (re.search(r'[^ ]+\..+',line[10:])).group()
            data = line[10:-1]
            name = line[10:-(len(version)+2)]
            sheet.append([data,name,version])

def FindFile():
    filenames = os.listdir(os.getcwd())
    for  name  in  filenames:
        filenames[filenames.index(name)] = name[: - 3 ]
        print(name)

if __name__ == "__main__":
    CreateXlsx()
    # FindFile()